package com.md.facade;

import com.md.api.RoleApi;
import com.md.application.service.RoleApplication;
import com.md.config.Logs;
import com.md.model.page.PageResponse;
import com.md.model.system.CommonResult;
import com.md.request.LinkApiRequest;
import com.md.request.LinkModuleRequest;
import com.md.request.QueryRolePageRequest;
import com.md.request.QueryRoleRequest;
import com.md.request.QueryUsersApiRequest;
import com.md.request.QueryUsersAppInfoRequest;
import com.md.request.QueryUsersModuleRequest;
import com.md.request.RoleRequest;
import com.md.request.UpdateStatusRequest;
import com.md.response.RoleResponse;
import com.md.response.UsersApiResponse;
import com.md.response.UsersAppInfoResponse;
import com.md.response.UsersModuleResponse;
import com.md.value.enums.OperationEnum;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 刘骄阳
 * 2024-12-15 1:41
 */
@RestController
@RequiredArgsConstructor
public class RoleController implements RoleApi {
  private final RoleApplication roleApplication;

  @Override
  @Logs(title = "创建角色", operation = OperationEnum.INSERT)
  public CommonResult<RoleResponse> create(final RoleRequest request) {
    return roleApplication.create(request);
  }

  @Override
  @Logs(title = "更新角色", operation = OperationEnum.UPDATE)
  public CommonResult<RoleResponse> update(final RoleRequest request) {
    return roleApplication.update(request);
  }

  @Override
  @Logs(title = "查询角色详情", operation = OperationEnum.SELECT)
  public CommonResult<RoleResponse> detail(final QueryRoleRequest request) {
    return roleApplication.detail(request);
  }

  @Override
  @Logs(title = "查询角色列表", operation = OperationEnum.SELECT)
  public CommonResult<PageResponse<RoleResponse>> list(final QueryRolePageRequest request) {
    return roleApplication.list(request);
  }

  @Override
  @Logs(title = "更新角色状态", operation = OperationEnum.UPDATE)
  public CommonResult<Void> updateStatus(final UpdateStatusRequest request) {
    return roleApplication.updateStatus(request);
  }

  @Override
  @Logs(title = "角色关联api", operation = OperationEnum.INSERT)
  public CommonResult<Void> linkApi(final LinkApiRequest request) {
    return roleApplication.linkApi(request);
  }

  @Override
  @Logs(title = "角色关联模块", operation = OperationEnum.INSERT)
  public CommonResult<Void> linkModule(final LinkModuleRequest request) {
    return roleApplication.linkModule(request);
  }

  @Override
  @Logs(title = "查询模块", operation = OperationEnum.SELECT)
  public CommonResult<PageResponse<UsersModuleResponse>> moduleList(final QueryUsersModuleRequest request) {
    return roleApplication.moduleList(request);
  }

  @Override
  @Logs(title = "查询应用", operation = OperationEnum.SELECT)
  public CommonResult<PageResponse<UsersAppInfoResponse>> appInfoList(final QueryUsersAppInfoRequest request) {
    return roleApplication.appInfoList(request);
  }

  @Override
  @Logs(title = "查询接口", operation = OperationEnum.SELECT)
  public CommonResult<PageResponse<UsersApiResponse>> apiList(final QueryUsersApiRequest request) {
    return roleApplication.apiList(request);
  }
}
